import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SPetExploreResult } from "../../../../../Message/Public/SPetExploreResult";
import { PetExploreConfig } from "../../../resource/PetExploreConfig";
import { Cache } from "../../../cache/Cache";
import { PetExploreAreaConfig } from "../../../resource/PetExploreAreaConfig";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { PetExploreConfigInfo } from "../../../resource/info/PetExploreConfigInfo";
import { PetExploreAreaInfo } from "../../../resource/info/PetExploreAreaInfo";
//class PetExploreResultTipPanel
    
    export  class PetExploreResultTipPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._nameTxt = ObjCreate.createTextField("", 0, 0, 220, 20, this);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._nameTxt.multiline = true;
            this._nextTxt = ObjCreate.createTextField("", 0, 20, 220, 20, this);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._nextTxt.htmlText = Language.getString(54491);
            this._nextTxt.addEventListener(flash.events.TextEvent.LINK, this.onNextClickHandler);
            this._viewTxt = ObjCreate.createTextField("", 0, 20, 220, 20, this);
            this._viewTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._viewTxt.htmlText = Language.getString(54492);
            this._viewTxt.addEventListener(flash.events.TextEvent.LINK, this.onViewClickHandler);
            this._progressTxt = ObjCreate.createTextField("", 0, 20, 220, 20, this, GlobalStyle.textFormat6);
            this._progressTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        public updateByExploreResult(arg1: SPetExploreResult): void
        {
            this._exploreResult = arg1;
            this._exploreConfig = PetExploreConfig.instance.getExploreConfigByLevel(this._exploreResult.currentLevel);
            if (arg1.isWin) 
            {
                this._nextExploreConfig = PetExploreConfig.instance.getExploreConfigByLevel(this._exploreResult.currentLevel + 1);
                this._nameTxt.htmlText = Language.getString(54493) + this._exploreConfig.name;
                this._nextTxt.y = this._nameTxt.height + 10;
                this._viewTxt.y = this._nextTxt.y + 20;
                this._progressTxt.y = 20;
                if (this._nextExploreConfig) 
                {
                    if (this._nextExploreConfig.area > Cache.instance.petExplore.getExploreAreaIndex()) 
                    {
                        this._nextAreaInfo = PetExploreAreaConfig.instance.getAreaConfigByArea(this._nextExploreConfig.area);
                        this._nameTxt.htmlText = Language.getStringByParam(54543, this._nextAreaInfo.name);
                        this._nextTxt.visible = false;
                        this._viewTxt.y = this._nextTxt.y + 40;
                        this._progressTxt.y = 45;
                    }
                    else 
                    {
                        this._nextTxt.visible = true;
                        this._nextTxt.y = this._nameTxt.height + 25;
                        this._viewTxt.y = this._nextTxt.y + 20;
                    }
                }
                else 
                {
                    this._nextTxt.visible = false;
                    this._nameTxt.htmlText = Language.getString(54528);
                }
            }
            else 
            {
                this._nameTxt.htmlText = Language.getStringByParam(54494, this._exploreConfig.name);
                this._nextTxt.visible = false;
                this._progressTxt.y = 45;
                this._viewTxt.y = this._nameTxt.height + 30;
            }
            this._progressTxt.text = Language.getString(54621) + this._exploreConfig.level + "/" + PetExploreConfig.instance.rbNum;
            return;
        }

        /* internal  */onNextClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=0;
            var loc2=false;
            var loc3=false;
            if (this._nextExploreConfig) 
            {
                loc1 = this._nextExploreConfig.level;
                loc2 = false;
                loc3 = false;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetExploreStart, {"startLevel": loc1, "isAutoExplore": loc2, "isDrawRewards": loc3, "callBack": this.onStartExploreReponse}));
            }
            return;
        }

        /* internal  */onStartExploreReponse(): void
        {
            Cache.instance.petExplore.initJoinPet();
            Dispatcher.dispatchEvent(new DataEvent(EventName.MsgTipWindowHide));
            return;
        }

        /* internal  */onViewClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.PetExploreOpen, true));
            Dispatcher.dispatchEvent(new DataEvent(EventName.MsgTipWindowHide));
            return;
        }

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nextTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_viewTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_progressTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_exploreResult: SPetExploreResult;

        /* internal */ /* var */_exploreConfig: PetExploreConfigInfo;

        /* internal */ /* var */_nextExploreConfig: PetExploreConfigInfo;

        /* internal */ /* var */_nextAreaInfo: PetExploreAreaInfo;
    }
